
PImage currentImage; 

void setImage(String filename) {
  //println(filename);
  try{ currentImage = loadImage(props.getProperty("absoluteDataPath") + filename); } 
  catch(Exception e) { }
  
  if(currentImage == null)
  {
    errorMessage = "No such image!";
  }
  else
  {
    // SCALE UP IMAGES ??
    //if(currentImage.height > Config.winHeight || currentImage.width > Config.winWidth)
    {
      float ratio;
      
      if(currentImage.height - props.getIntProperty("viewport.height") > currentImage.width - props.getIntProperty("viewport.width"))
        ratio = (float) props.getIntProperty("viewport.height") / currentImage.height;
      else
        ratio = (float) props.getIntProperty("viewport.width") / currentImage.width;
        
      currentImage.resize(floor(currentImage.width*ratio + 0.5), floor(currentImage.height*ratio + 0.5));
    }
  }
}

void displayImage() {
  if(currentImage != null) {
    image(currentImage, 
          props.getIntProperty("viewport.width")/2 - currentImage.width/2, 
          props.getIntProperty("viewport.height")/2 - currentImage.height/2); 

    fill(255, 255, 255);
    //text("ID: " + currentImageEntry.id + "\nFilename: " + currentImageEntry.fileName + "\nScore: " + currentImageEntry.rateTotal, 15, 30); 
  }
}

